package sicnu.cs.aps.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.validation.Valid;
import javax.validation.constraints.Min;

@Data
@Configuration
@ConfigurationProperties("app")
public class AppProperties {

    @Valid
    private Jwt jwt = new Jwt();

    private Client client = new Client();

    @Data
    public static class Jwt {
        private String header = "Authorization"; // HTTP 报头的认证字段的 key

        private String prefix = "Bearer "; // HTTP 报头的认证字段的值的前缀

        @Min(5000L)
        private long accessTokenExpireTime = 12 * 60 * 60 * 1000L; // Access Token 过期时间

        @Min(3600000L)
        private long refreshTokenExpireTime = 30 * 24 * 3600 * 1000L; // Refresh Token 过期时间

        private String key;

        private String refreshKey;

    }

    @Data
    public static class Client {
        private String ip = "ich.com";
    }

}
